;(function () {
    $.fn.extend({
        //插件名字
        pluginname: function () {
            //$('body').append('sdfsdf');
        }
    });
})(jQuery);

$(function () {
    modal = {};

    /**
     * 电脑端提示插件
     * @param message 提示内容
     * @param open_timeout 是否打开自动关闭
     * @param timeout 关闭时间
     * @param open_close 是否打开手动关闭
     * @param title_message 手动关闭提示标题
     */
    modal.weblayermodal = function (message, open_timeout, timeout, open_close, title_message) {
        var modaltop = '';
        if (open_close == true || open_close == 'open') {
            modaltop = '<div class="web-modal-top">' +
                '<dl style=" margin-bottom: 10px; padding: 0;line-height: 30px;height: 30px;border-bottom: solid 1px #dddddd;">' +
                '<dt style="float: left;font-size: 14px;">' + title_message + '</dt>' +
                '<dd class="modal-close" onclick="$(\'.web-layer-modal,.web-modal\').remove();" style="float: right;font-size: 14px;cursor: pointer;text-align: center;">×</dd>' +
                '</dl></div>';
        }
        var weblayermodal = '<div class="web-layer-modal" style=" background: rgba(0, 0, 0, 0.25);position: fixed;width: 100%;height: 100%;left: 0;top: 0;z-index: 99;"></div>';
        var modalmodalcontent = '<div class="modal-modal-content" style="background: #ffffff;color: #000000;padding: 10px;">' + modaltop + '<div>' + message + '</div></div>';
        var modalmodal = '<div class="modal-modal" style=" border-radius: 0px;display: inline-block;box-shadow: -1px -1px 8px #555555;background: rgba(0, 0, 0, 0.55);padding: 10px;margin-left: -15px;border: solid 1px #333444;">' + modalmodalcontent + '</div>';
        var webmodal = '<div class="web-modal" style=" text-align: center;width: 100%;top: 50%;position: fixed;z-index: 999;">' + modalmodal + '</div>';
        $('body').append(weblayermodal + webmodal);
        var webModal = $('.web-modal');
        var modalheight = webModal.height();
        webModal.css({'margin-top': -modalheight / 2});
        if (open_timeout == true || open_timeout == 'open') {
            if (timeout == undefined || timeout == "") timeout = 1000;
            setTimeout(function () {
                $('.web-layer-modal,.web-modal').remove();
            }, timeout);
        }
    };

    /**
     * 手机端提示插件
     * @param message 提示内容
     * @param timeout 关闭时间
     */
    modal.mobilelayermodal = function (message, timeout) {
        var layermodal = '<div class="layer-modal" style="background: rgba(0, 0, 0, 0.35);position: fixed;width: 100%;height: 100%;left: 0;top: 0;z-index: 99;"></div>';
        var modalmessage = '<div class="modal" style=" text-align: center;width: 100%;top: 50%;margin-top: -25px;position: fixed;z-index: 999;"><span style="background: rgba(0, 0, 0, 0.75);line-height: 50px;color: #ffffff;border-radius: 3px;display: inline-block;padding: 0 50px;">' + message + '</span></div>';
        if (timeout == undefined || timeout == "") timeout = 1000;
        $('body').append(layermodal + modalmessage);
        setTimeout(function () {
            $('.layer-modal,.modal').remove();
        }, timeout);
    };
    modal.run = function () {
        this.weblayermodal("<p>错误提示内容或其他内容</p>", true, 2000, true, '提示标题');
        //this.mobilelayermodal("错误提示框");
    };
    modal.run();
});